package ${package};

import com.ahccc.common.util.StrUtil;
import com.ahccc.common.util.bootStrapTable.PageVO;
import com.ahccc.data.service.GenericManagerImpl;
import com.ahccc.data.utils.FieldFilter;
import com.ahccc.data.utils.QueryFilter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import ${modelpackage}.${name};
import ${repositorypackage}.${name}Dao;
import ${servicepackage}.${name}Manager;
/**
* @copyright:${copyright}
* @Author:${author}
* @Date:${datetime}
* @Description:
*/
@Service
public class ${name}ManagerImpl extends GenericManagerImpl<${name}, <#list fields as f>${f.javaType} </#list>> implements ${name}Manager {

	${name}Dao ${sname}Dao;

	@Autowired
	public ${name}ManagerImpl(${name}Dao genericDao) {
		super(genericDao);
		${sname}Dao = genericDao;
	}

	@Override
	public PageVO findAll(${name} ${sname}, Sort sort, Integer pageNumber, Integer pageSize) {
		QueryFilter queryFilter = new QueryFilter();
		<#list fields as f >
        if (!StrUtil.isEmpty(${sname}.get${f.fixCode}())){
        	queryFilter.add("${f.simpleName}", FieldFilter.OP.EQ, ${sname}.get${f.fixCode}());
        }
		</#list>
		Pageable pageable =PageRequest.of(pageNumber - 1, pageSize, sort);
		Page<${name}> list = dao.findAll(queryFilter.toArray(), pageable);
	    return new PageVO(list.getContent(), (int) list.getTotalElements());
	}

}
